package com.market.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.market.domain.transients.DAY_OF_WEEK;

@Entity
@Table(name = "purchaseschedule")
public class PurchaseSchedule extends BaseObject {

	

	/**
	 * 
	 */
	private static final long serialVersionUID = -5245700139975369181L;
	
	
	@Override
	public boolean equalsId(Object o) {
		if ((o instanceof PurchaseSchedule) && ((PurchaseSchedule)o).getId().equals(this.id)) {
			return true;
		}

		return false;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id = 0L;
	@Enumerated
	private DAY_OF_WEEK dayOfWeek;
	@Column(nullable = false, columnDefinition = "INT DEFAULT 16")
	private int purchaseHour = 16;
	@Column(nullable = false, columnDefinition = "INT DEFAULT 0")
	private int purchaseMinute = 0;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public DAY_OF_WEEK getDayOfWeek() {
		return dayOfWeek;
	}
	public void setDayOfWeek(DAY_OF_WEEK dayOfWeek) {
		this.dayOfWeek = dayOfWeek;
	}
	
	public int getPurchaseHour() {
		return purchaseHour;
	}
	public void setPurchaseHour(int purchaseHour) {
		this.purchaseHour = purchaseHour;
	}
	public int getPurchaseMinute() {
		return purchaseMinute;
	}
	public void setPurchaseMinute(int purchaseMinute) {
		this.purchaseMinute = purchaseMinute;
	}
	
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((dayOfWeek == null) ? 0 : dayOfWeek.hashCode());
		result = prime * result + purchaseHour;
		result = prime * result + purchaseMinute;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PurchaseSchedule other = (PurchaseSchedule) obj;
		if (dayOfWeek != other.dayOfWeek)
			return false;
		if (purchaseHour != other.purchaseHour)
			return false;
		if (purchaseMinute != other.purchaseMinute)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "PurchaseSchedule [id=" + id + ", dayOfWeek=" + dayOfWeek
				+ ", hour=" + purchaseHour + ", minute=" + purchaseMinute + "]";
	}
	
	

}
